Skip to content

update documentation and skills - #489

Merged
davidkoski merged 2 commits into
mainfrom
update-docs
Sep 30, 2026
Merged

davidkoski merged 2 commits into
mainfrom
update-docs

Conversation

@davidkoski

Copy link
Copy Markdown
Member

Proposed changes

  • make sure we are using current best practices e.g. for #huggingFaceTokenizerLoader()
  • where found, update skills to current API

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@davidkoski
davidkoski requested a review from angeloskath July 31, 2026 15:58
Comment on lines +13 to +16
let modelContainer = try await EmbedderModelFactory.shared.loadContainer(
from: #hubDownloader(),
using: #huggingFaceTokenizerLoader(),
configuration: EmbedderRegistry.nomic_text_v1_5

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some stragglers using the old API

let texts = ["First text", "Second text", "Third text"]

let embeddings = await container.perform { model, tokenizer, pooler in
let embeddings = await container.perform { context in

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this to the non-deprecated form of the call. Note that all of this will be obsolete with #335

@CharlieTLe CharlieTLe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

- make sure we are using current best practices e.g. for #huggingFaceTokenizerLoader()
- where found, update skills to current API
let container = try await LLMModelFactory.shared.loadContainer(
from: HubClient.default,
using: TokenizersLoader(), // TokenizersLoader() from MLXLMTokenizers (swift-tokenizers-mlx)
from: #hubDownloader(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need updated imports here (import MLXHuggingFace, import HuggingFace and import Tokenizers)

let container = try await LLMModelFactory.shared.loadContainer(
from: HubClient.default,
using: TokenizersLoader(),
from: #hubDownloader(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need updated imports here (import MLXHuggingFace, import HuggingFace and import Tokenizers)

// etc.
import MLXLMCommon
import MLXHuggingFace
import Tokenizers

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs import HuggingFace

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nwh added


`#huggingFaceTokenizerLoader()` delegates to `Tokenizers.AutoTokenizer`, which maps the
`tokenizer_class` from `tokenizer_config.json` onto its own built-in implementations and
falls back to a BPE tokenizer for unknown classes. If that is not what you want, write

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a huge issue, but this isn't quite true as stated. AutoTokenizer.from(modelFolder:) only falls back to BPE if strict=false, but by default, it's true. In the default case, it doesn't fall back - it throws unsupportedTokenizer. So people should still make their own tokenizer if they care very much about this but it might be more to avoid errors than to avoid fallbacks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to propose a rephrase? Perhaps just noting that you can write a custom TokenizerLoader that does fall back to BPE would be more correct.

import MLXLLM
import MLXLMCommon

import IntegrationPackage

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it desired to remove this? I'm a little confused by this example - with the proposed changes, it now shows a generic HuggingFace macro example (identical to the previous section) rather than an IntegrationPackage-specific example.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, when the 3.x mlx-swift-lm was cut we had an integration package to document. We no longer have that (the author stopped supporting it and retracted it).

@aleroot is working on one that could be documented here when he wants to promote it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@davidkoski sure, after the release I will add a PR(probably after #619) with the option for https://github.com/aleroot/swift-tokenizers , on my app is working well already for awhile now. The only thing is that: I do not plan to add any downloader to that library. The library is however fully drop in replacement for the swift-transformers.

Comment on lines +41 to +42
`#huggingFaceTokenizerLoader()` macro provides a concrete loader backed by Swift
Tokenizers' `AutoTokenizer`:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to change the "Swift Tokenizers" reference to "Swift Transformers".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to change the "Swift Tokenizers" reference to "Swift Transformers".

@@ -263,7 +266,7 @@ Users who were passing a custom `HubApi` instance should create a `HubClient` in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to change the "Swift Tokenizers" reference to "Swift Transformers".

@davidkoski
davidkoski merged commit ac6f565 into main Sep 30, 2026
5 checks passed
@davidkoski
davidkoski deleted the update-docs branch September 30, 2026 22:28
wballard added a commit to swissarmyhammer/mlx-swift-lm-old that referenced this pull request Oct 3, 2026
Apply the upstream commits ee673d6..55db721 as a 3-way patch. CLAUDE.md is
excluded.

- c043fb3 pick up mlx-swift 0.32.2 (ml-explore#646)
- 0493daf Named image attachments in MLXLMCommon and the Foundation Models adapter (ml-explore#535)
- 0dcfe2f Convert the booleans in tool parameter schemas to Swift Bool values (ml-explore#653)
- 37dab60 be able to trigger workflows on main. notes about upcoming releases. (ml-explore#647)
- 390c5fd require mlx-swift-0.32.3 for SDK issue (ml-explore#657)
- 3b339ad adjustments for running tests on NAX/TF32 hardware (ml-explore#649)
- ac6f565 update documentation and skills (ml-explore#489)
- ce3950e Drop MTP weights from converted Qwen 3.5 VLM checkpoints (ml-explore#642)
- 9112fae Synchronize cross-SIMD WHT reads before shared-memory writes (ml-explore#650)
- 7e4024e NemotronH: MoE keys are optional, so dense checkpoints load (ml-explore#635)
- 1830ae4 Declare the fused GDN projection as compile state so it frees with the model (ml-explore#631)
- 6e0a0b2 Synchronize Metal before checking cached buffer memory (ml-explore#667)
- 9afc3b5 Recommend upToNextMinor in installation instructions (ml-explore#668)
- 55db721 Reduce Qwen3 reranking memory by projecting final tokens only (ml-explore#621)

Conflict resolutions:

- MLXLanguageModel.swift: keep the drain coordinator and runRespond of
  stable, and keep historyMessages. Add the upstream attachment label
  validation before resolveConfiguration. historyMessages now throws,
  because TranscriptConverter.mlxMessages now throws.
- TranscriptConverter.swift: keep the mlxMessages(for:replayReasoning:) and
  convert(entry:) form of stable. Apply the upstream changes in
  convert(entry:): it throws, an instructions entry drops its images, and
  extractImages(from:in:) applies the orientation and rejects content that
  is not an image.
- Chat.swift: keep the doc comments of stable, and add the upstream
  MessageContentLayout and contentParts(for:layout:).
- TurboQuantKernels.swift: keep stable. Stable already fixed the same
  cross-SIMD WHT race with two barriers per stage.
- KVCacheTests.swift: take the upstream file (upstream changed it to a
  suite). Delete the upstream ArraysCache.advance test, because in this fork
  advance(_:) also moves offset. Add the fork tests for advance and the
  trim-then-continue test at file scope.
- Qwen35FusedGDNProjectionTests.swift: keep the deletion of the opt-in
  benchmark (it skips unless an environment variable is set). Add the new
  upstream memory test.
- model-container.md: take upstream (llama3_2_3B_4bit and the macros are
  the real API).
- TranscriptConverterTests.swift: the replayReasoning calls now use try.

Tests: MLXGuidedGenerationTests 70, MLXFoundationModelsTests 349,
CXGrammarTests 7, MLXHuggingFaceMacrosTests 5 pass. MLXLMTests: 1287 Swift
Testing tests pass, and 699 of 700 XCTest tests pass. The failure is the
wall-clock limit of EvalTests
testVarianceNormalizedKVCache32KIngestAndDecodePeakMetalMemorySmoke (0.29 s,
limit 0.25 s) in the full run. The test passes alone two times, and this
merge does not change EvalTests.swift.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
div0-space pushed a commit to LibraxisAI/mlx-swift-lm that referenced this pull request Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants